package cn.lotusnut.rabbitmqboot.direct;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author JiangMing Zhou
 * @Date 2022/12/1 15:19
 * @Version 1.8
 */
@Component
public class DirectProvider {
    @Resource
    private AmqpTemplate amqpTemplate;

    public void sendMessage(String message) {
        for (int i = 0; i < 10; i++) {
            amqpTemplate.convertAndSend("direct_exchange", i < 5 ? "red" : "green", message + i);
        }

    }

}
